#include<stdio.h>

int main()
{
	int a;
	int b;
	int c;
	scanf_s("%d%d", &a, &b);
	while (c = a % b)
	{
		a = b;
		b = c;
	}

	printf("%d\n", b);
	return 0;
}